package org.loon.game.sample.llk;

import org.loon.framework.javase.game.core.graphics.LFont;
import org.loon.framework.javase.game.core.graphics.component.LPaper;
import org.loon.framework.javase.game.core.graphics.opengl.GLColor;
import org.loon.framework.javase.game.core.graphics.opengl.GLEx;
import org.loon.framework.javase.game.core.graphics.opengl.LTexture;

public class pGrid extends LPaper {
	
	boolean clicked = false;
    LTexture show;
	int Xpos,Ypos;
	String type = "";
	private LFont font = LFont.getDefaultFont();
	
	public LTexture getShow() {
		return show;
	}

	public void setShow(LTexture show) {
		this.show = show;
	}

	public pGrid(int x, int y, int w, int h) {
		super(x, y, w, h);
		// TODO Auto-generated constructor stub
	}
	
	public pGrid(int x, int y, int w, int h,int xPos,int yPos,String type){
		this(x, y, w, h);
		this.Xpos = xPos;
		this.Ypos = yPos;
		this.type = type;
	}
	
	public pGrid(LTexture background, int x, int y,int xPos,int yPos,String  type) {
		this(x,y,background.getWidth(),background.getHeight());
		show = background;
		this.Xpos = xPos;
		this.Ypos = yPos;
		this.type = type;
	}
	
	public pGrid(pGrid grid){
		this(grid.x(),grid.y(),grid.getWidth(),grid.getHeight());
		show = grid.getShow();
		Xpos = grid.Xpos;
		Ypos = grid.Ypos;
		type = grid.type;
		setVisible(grid.isVisible());
	}
	/*public pGrid(LTexture background, int x, int y) {
		super(background, x,y);
	}*/
	
	public void createCustomUI(GLEx g, int x, int y, int w, int h) {
		if (show != null) {
			if (clicked) {
				g.drawTexture(show, this.x(), this.y(), GLColor.red); // 该函数可能有bug,有时候遮罩效果不能出现
				g.setColor(GLColor.red);
				g.fillRect(x, y, w, h);
			} else {
				g.drawTexture(show, this.x(), this.y());
			}
		} else {
			g.setColor(GLColor.red);
			if (type.equals("N")) {
				g.drawLine(x+1, y+1, x+w, y+h);
				g.drawLine(x+w, y+1, x, y+h);
			}
			g.drawRect(x + 1, y + 1, w - 1, h - 1);
		}
		g.resetColor();
	}

public int getXpos() {
	return Xpos;
}

public void setXpos(int xpos) {
	Xpos = xpos;
}

public int getYpos() {
	return Ypos;
}

public void setYpos(int ypos) {
	Ypos = ypos;
}

/*
public boolean equals(Object obj){
	pGrid pg = (pGrid)obj;
	return this.type.equals(pg.type);
}*/

}
